
import com.wider.foundation.DLogger;
import com.wider.foundation.DLoggerRoot;
import com.wider.foundation.event.Event;
import com.wider.foundation.event.EventHub;
import com.wider.foundation.event.EventListener;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author William
 */
public class eventTest {
    public static void func(Object...objs){
        if (objs.length < 1){
            System.out.println("Nth");
        }else{
            System.out.println("Yes");
        }
    }

    public static void main(String args[]){
        DLoggerRoot logger = DLogger.getRoot();
        logger.setStream(System.out);
        logger.setLevel(DLogger.DLevel.DEBUG);
        logger.enable();
        
        EventHub ehub1 = new EventHub();
        ehub1.addEventListener("onClick", new EventListener(){
            @Override
            public void handleEvent(Event event) {
                System.out.println("@@ " + event.toString());
            }

        });

        ehub1.addEventListener("onClick", new EventListener(){
            @Override
            public void handleEvent(Event event) {
                System.out.println("## " + event.toString());
            }
        });

        ehub1.addEventListener("onMouseover", new EventListener(){
            @Override
            public void handleEvent(Event event) {
                System.out.println("HOVER: " + event.toString());
            }
        });

        Set<String> events;

        events = ehub1.getListeningEvents("onmove", "onMouseover");
        System.out.println("-- " + events.size());
        for (String str : events){
            System.out.println("-- " + str);
        }


        ehub1.fire(new Event("onClick", ehub1, ehub1));
        ehub1.fire(new Event("onMouseover", ehub1, ehub1));
        ehub1.fire(new Event("onMouseover", ehub1, ehub1));
        ehub1.fire(new Event("onClick", ehub1, ehub1));

        
        //Shut-down the EventHub
        try {
            ehub1.shutdown();
        } catch (InterruptedException ex) {
            Logger.getLogger(eventTest.class.getName()).log(Level.SEVERE, null, ex);
        }
        
         
        System.out.println("done");

        func();

        return;
    }
}
